#include <libavformat/avio.h>

int main(int argc, char const *argv[])
{
    int ret;
    AVIOContext *avio_input_server_ctx = NULL;
    AVDictionary *in_opts = NULL;

    // av_dict_set(&in_opts, "timeout", "2", 0);
    av_dict_set(&in_opts, "listen", "2", 0);

    // note: rtmp can't listen multi client by default. tcp can do.
    //
    avio_open2(&avio_input_server_ctx, "rtmp://0.0.0.0:1935/stream/live", 0, NULL, &in_opts);
    // avio_open2(&avio_input_server_ctx, "tcp://0.0.0.0:1935", 0, NULL, &in_opts);

    while (1)
    {
        AVIOContext *client = NULL;
        if (avio_accept(avio_input_server_ctx, &client) < 0)
        {
            break;
        }
    }

    return 0;
}
